writing binary data to files